﻿using Newtonsoft.Json;

namespace Baby.Shop.Application.Common
{
    public static class WxHelp
    {
        /// <summary>
        /// Oppenid
        /// </summary>
        /// <param name="code">公众号凭证密码</param>
        /// <returns></returns>
        public static WxLoginDTO GetBaseCode(string appid,string sercet,string wxlogiurl,string code)
        {
            string OpenId = string.Empty;
            string resultStr =HttpHelp.HttpGet(wxlogiurl, "appid=" + appid + "&secret=" + sercet + "&js_code=" + code + "&grant_type=authorization_code");
            var data = JsonConvert.DeserializeObject<WxLoginDTO>(resultStr);
            return data;
        }
        public class WxLoginDTO
        {
            /// <summary>
            /// 
            /// </summary>
            public string openid { get; set; }
            /// <summary>
            /// 
            /// </summary>
            public string unionid { get; set; }
        }
    }
}
